<template>
	<view :class="currentTheme">
		<a-nabbar name="切换DM"/>
		<view v-if="personList.length" class="u-padding-32">
			<item-box padding="0">
				<view class="group-box">
					<v-radio :name="item.value" v-for="(item, index) in personList" :key="index"  v-model="form.dmUid">
						<view class="text-white-black-reversal u-font-32 u-padding-top-66 u-padding-bottom-66" :class="{'u-border-bottom':index>personList.length - 1}">{{item.label}}</view>
					</v-radio>
				</view>
			</item-box>
		</view>
		<fixed-team btnText="确定" @btnClick="save"></fixed-team>
	</view>
</template>

<script>
	import {getDetail,add} from '@/api/crud.js'
	import vRadio from '@/components/itemRadio/itemRadio.vue'
	export default {
		components: {
			vRadio
		},
		data() {
			return {
				form:{
					dm:'',
					dmUid:''
				},
				personList:[],
				loading:false,
				apiModule:'shopApi',
				apiType:'gatherGame',
				option:{}
			};
		},
		onLoad(option) {
			this.option = option;
			// this.form.dm = option.dmUsername
			this.form.dmUid = option.dmUid
			getDetail(option,'systemStoreUser',this.apiModule,'list').then(res=>{
				this.personList = res.map(val=>({label:`${val.nickname}【${val.userType}】`,value:val.uid}));
			})
		}, 
		methods: {
			getIds(id){
				this.form.dmUid = id;
			},
			//切换dm
			save() {
				let {dmUid} = this.form;
				if(!dmUid){
					this.$u.toast('请选择DM')
					return false;
				}
				let form = {...this.form,gatherGamedId:this.option.teamId,storeId:this.option.storeId}
				add(form,this.apiType,this.apiModule,'updateGatherGameDm').then(res=>{
					this.$u.toast('操作成功');
					this.$u.route({
						type:'back'
					})
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
.group-box{
	padding-left: 47rpx;
}
</style>

